import { createAndInitilalizeTable } from '@/components/table/lib';
import { ready, assert, getApiPath } from '@/lib/utils.ts';

import {
    IDCol,
    tf,
} from '@/components/table/lib';

function initializeTable(url: string) {
    const table_elem = document.getElementById("table");
    assert(table_elem, "Element with ID 'table' not found");
        
    createAndInitilalizeTable(
        url,
        table_elem,
        {
            columnDefs: [
                IDCol,
                {
                    ...tf("contract_name", "合同名称"),
                    minWidth: 200,
                    flex: 1,
                },
                {
                    ...tf("contract_time", "主合同签订时间"),
                    type: 'date',
                },
                {
                    ...tf("date_of_submission_contract_by_sponsor", "申办方提交合同日期"),
                    type: 'date',
                },
                {
                    ...tf("contract_agreement_date", "合同协商一致日期"),
                    type: 'date',
                },
                {
                    ...tf("contract_amount", "主合同签订金额"),
                    width: 200
                },
                {
                    ...tf("management_fee", "机构管理费到位"),
                    width: 200
                },
                {
                    ...tf("funds_appropriation", "合同款项拨付"),
                    width: 200
                },
            ]
        }
    );
}

(function () {
    ready(() => {
        initializeTable(getApiPath());
    });
})();

